package cgl.narada.samples.nbNative;

import cgl.narada.service.ServiceException;
import cgl.narada.service.client.ClientService;

public class ClientTransmissionTracker extends Thread {

	
	private ClientService clientService;
	private boolean keepLooping = true;
	private String moduleName = "ClientTrasmissionTracker: ";
	
	public ClientTransmissionTracker(ClientService clientService) {
		this.clientService = clientService;
	}
	
	public void stopLooping() {
		keepLooping = false;
	}
	
	public void run()  {
		keepLooping = true;
		while (keepLooping) {
			try {
				if (clientService.hasPendingTransfers()) {
					System.out.println(moduleName + "There are pending transfers");
				}
				sleep(50);
			} catch (ServiceException e) {
				System.out.println(moduleName + "Error checking transfers " + e);
				e.printStackTrace();
			} catch (InterruptedException e) {
				System.out.println(moduleName + "Error sleeping " + e);
			}
			
		} /* end while()*/
		
		System.out.println(moduleName + "Termininating transmission tracker ..");
		
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
